<template>
  <div id="iframe-box">123</div>
  <iframe
    id="discordId"
    ref="iframeInstance"
    src="https://discord.com/channels/662267976984297473/981697648119648266"
    frameborder="0"
    sandbox="allow-scripts allow-same-origin allow-forms"
    @load="onIframeLoad"
  ></iframe>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { ipc } from '@renderer/utils'

const iframeInstance = ref(null)

// onMounted(() => {
//   ipc.send('get-iframe-localstorage')
// })

onMounted(() => {
  console.log(iframeInstance.value.contentWindow.localStorage, 'onMounted')
  console.log(iframeInstance.value.contentWindow, 'onMounted')
  iframeInstance.value.contentWindow.localStorage.setItem(
    'token',
    JSON.stringify('MTEzMTc3MzAwNjU5MTU3MDA2MQ.Gx6we0.ayqXudKSMyzpXq8ra83GUraDb6nhblHU2d4NWk')
  )
})

const onIframeLoad = () => {
  console.log(iframeInstance.value.contentWindow.localStorage, 'onIframeLoad')
}
</script>
<style>
iframe {
  width: 100vw;
  height: 100vh;
}
</style>
